package com.realgodo.site.service.application;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.orm.hibernate.DefaultEntityManager;

import com.realgodo.site.entity.application.secret.SecretJoiner;


@Service
@Transactional
public class SecretJoinerManager extends DefaultEntityManager<SecretJoiner, Long> {
	@Autowired
	private SessionFactory sessionFactory;
	
	
	/**
	 * 取得参与者列表
	 * @param secretId
	 * @param size <=0全部读取
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<SecretJoiner> getSecretJoinerList(Long secretId,int size){
		Criteria c = sessionFactory.getCurrentSession().createCriteria(SecretJoiner.class);
		c.add(Restrictions.eq("secret.id", secretId));
		if(size>0){
			c.setMaxResults(size);
		}
		return c.list();
	}
	
}
